package com.gxl.design.observerpattern;

import com.gxl.design.observerpattern.observer.MyObserver;

import java.util.ArrayList;
import java.util.List;

public class Bill {

    private List<MyObserver> observers = new ArrayList<>();

    public void observer(MyObserver myObserver){
        observers.add(myObserver);
    }
    public void  generatedBill(final Integer money){
        System.out.println("生成账单金额 :  " + money + " 元.");
        notiyObserverList();
    }

    private void notiyObserverList() {
        for (MyObserver observer : observers) {
            observer.excute();
        }
    }


}
